package com.fc.mall.controller;/**
 * Created by Administrator on 2019/10/13.
 */

import com.fc.mall.base.object.Result;
import com.fc.mall.dto.CommonResult;
import com.fc.mall.dto.SmsFriendsCirclesQueryParam;
import com.fc.mall.model.SmsFriendsCircles;
import com.fc.mall.service.SmsFriendsCirclesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author Climb
 * @Date 2019/10/13
 **/
@RestController
@Api(tags = "SmsFriendsCirclesController", description = "好友圈管理")
@RequestMapping("/friends")
public class SmsFriendsCirclesController {
    @Autowired
    SmsFriendsCirclesService friendsCirclesService;

    @ApiOperation("获取列表")
    @GetMapping("list")
    public CommonResult list(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                             SmsFriendsCirclesQueryParam queryParam){
        return new CommonResult().pageSuccess(friendsCirclesService.getList(queryParam,pageSize,pageNum));
    }

    @ApiOperation("通过Id获取好友朋友圈")
    @GetMapping("get/{id}")
    public Result getById(@PathVariable(name = "id") Long id){
        return Result.success(friendsCirclesService.getById(id));
    }

    @ApiOperation("增加或修改")
    @PostMapping("update")
    public Result createOrUpdate(@RequestBody SmsFriendsCircles friendsCircles){
        friendsCirclesService.createOrUpdate(friendsCircles);
        return Result.success();
    }

    @DeleteMapping("delete/{id}")
    public Result del(@PathVariable(name = "id") Long id){
        friendsCirclesService.delById(id);
        return Result.success();
    }
}
